package resources.reservations;

import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;

import model.reservation.lectureRoom.Reservation;
import dao.Linker;
import dao.ReservationLRDAO;

public class ReservationLRScheduleRes 
{
	@Context
	UriInfo uriInfo;
	
	@Context
	Request request;
	
	String reservationId;
	
	public ReservationLRScheduleRes(UriInfo uriInfo, Request request, String reservationId) 
	{
		this.uriInfo = uriInfo;
		this.request = request;
		this.reservationId = reservationId;
	}
	
	@GET
	@Produces(MediaType.TEXT_XML)
	public Reservation getDataBrowser() 
	{
		Linker.sort();
		
		Reservation reservation = ReservationLRDAO.getReservationCP().get(reservationId);
		
		if(reservation == null)
			throw new RuntimeException("Get: Reservation of lecture room " + reservationId +  " not found");
		return reservation;
	}
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public Reservation getDataBrowserJSON() 
	{
		return getDataBrowser(); 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_XHTML_XML)
	public Reservation getDataBrowserXHTML() 
	{
		return getDataBrowser(); 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_XML)
	public Reservation getDataBrowserXML() 
	{
		return getDataBrowser(); 
	}
}